<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录页面</title>
  <script src="./jquery.js"></script>
</head>

<body>
  <!-- 登录表单 -->
  <form id="form1">
    <div>账号：<input type="text" name="username" autocomplete="off" /></div>
    <div>密码：<input type="password" name="password" /></div>
    <button>登录</button>
  </form>

  <script>
    $('form').on('submit', function (e) {
      e.preventDefault()
      $.ajax({
        url: '/api/login',
        type: 'post',
        data: {
          username: 'admin',
          password: '123456'
        },
        success: function (res) {
          console.log(res, 66666)
          localStorage.setItem('token',res.token)
          if (res.code == 1) {
            location.href = './index.html'
          }
        },
      })
    })
  </script>




</body>

</html>